package com.springboot.blog.handler;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class MyMetaObjectHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("classifyCreateTime",new Date(),metaObject);
        this.setFieldValByName("blogCreatetime",new Date(),metaObject);
        this.setFieldValByName("blogCreateTime",new Date(),metaObject);
        this.setFieldValByName("shopTime",new Date(),metaObject);
        this.setFieldValByName("logtime",new Date(),metaObject);
        this.setFieldValByName("updateTime",new Date(),metaObject);
        this.setFieldValByName("commentCreateTime",new Date(),metaObject);
        this.setFieldValByName("usercreatetime",new Date(),metaObject);
        this.setFieldValByName("userupdatetime",new Date(),metaObject);
        this.setFieldValByName("classifyVersion",1,metaObject);
        this.setFieldValByName("available",0,metaObject);
        this.setFieldValByName("status",1,metaObject);
        this.setFieldValByName("classifyDeleted",0,metaObject);
        this.setFieldValByName("yqDelete",0,metaObject);
        this.setFieldValByName("shopDelete",0,metaObject);
        this.setFieldValByName("blogDeleted",0,metaObject);
        this.setFieldValByName("blogGgdetele",0,metaObject);
        this.setFieldValByName("commentDeleted",0,metaObject);
        this.setFieldValByName("blogViews",0,metaObject);
        this.setFieldValByName("deleted",0,metaObject);
        this.setFieldValByName("logdelete",0,metaObject);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime",new Date(),metaObject);
        this.setFieldValByName("blogUpdateTime",new Date(),metaObject);
        this.setFieldValByName("userupdatetime",new Date(),metaObject);
    }
}
